<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<meta name="viewport" content="user-scalable=no, initial-scale=1.0, maximum-scale=1.0, width=device-width">
	<meta name="apple-mobile-web-app-capable" content="yes">
	<meta content="black" name="apple-mobile-web-app-status-bar-style">
	<meta name="format-detection" content="telephone=no">
	<meta content="telephone=no" name="format-detection">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
	<link rel="stylesheet" media="screen and (max-width:900px)" href="/assets/stylesheets/style_wap.css" type="text/css" />
	<link rel="stylesheet" media="screen and (min-width:900px)" href="/assets/stylesheets/style_pc.css" type="text/css" />
	<title>登录</title>
</head>
<body>
	<div class="html login">
		<div class="cont center">
			<p class="lgtil">会员登录</p>
			<p class="lgline"><img src="/assets/images/icon_name.png" class="lgico"><input type="text" name="username" id="J_name" class="J_ctrol ctrol" data-target="username" placeholder="用户名"></p>
			<p class="lgline"><img src="/assets/images/icon_pwd.png" class="lgico"><input type="password" name="password" id="J_pwd" class="J_ctrol ctrol" data-target="password" placeholder="登录密码"></p>
			<!--
			<p class="lgline"><img src="/assets/images/icon_yzm.png" class="lgico"><input type="password" name="" id="J_yzm" class="J_ctrol ctrol" data-target="yzm" placeholder="验证码"><img src="img/yzm.jpg" class="yzm"></p>
			 -->
			<p class="lgbtn"><a href="javascript:;" class="btn btn_lg btn_rd30" id="J_btn">登录</a></p>
			<a href="forgetPassword" class="lgfor">忘记密码？</a>
		</div>
	</div>
	<script language="javascript" type="text/javascript" src="/assets/javascript/jquery-2.1.4.min.js"></script>
	<script language="javascript" type="text/javascript" src="/assets/javascript/func.js"></script>
	<script type="text/javascript">
		$(function(){

			$('.J_ctrol').blur(function(){
				var self = $(this),
					val = self.val().trim(),
					tar = self.attr('data-target');

				if(val){
					self.val(val);
					data[tar] = val; // 数据填充
				};
			})

			var J_name = $('#J_name'),
				J_pwd = $('#J_pwd'),
				J_btn = $('#J_btn'),
				isajax = false, // 设置开关
				data = {};

			J_btn.click(function(){
				console.log(data);
				if(isajax){return false;}

				if(!data.username){
					errormsg(J_name,'请输入用户名');
					return false;
				};
				if(!data.password){
					errormsg(J_pwd,'请输入密码');
					return false;
				};
				//ajax提交数据
				//alert('提交的数据：'+JSON.stringify(data));
				isajax = true;
				J_btn.html("正在登录···");
				$.ajax({
					type: "POST",
					url: "/general_login?v="+(new Date().getTime()),
					data: data,
					dataType: "json",
					success: function(res){
						console.log(res);
						if(res.code==0){
							// 提交成功
							console.log("登录成功");
							window.location.href = '/'; // 跳转
						}else{
							errormsg(J_pwd,'账户名或密码错误')
							J_btn.html("提交");
						};
					},
					complete:function(){
						isajax = false;
					}
				});

			});
		});
	</script>
</body>
</html>
